 package handling.channel.handler;


import client.MapleCharacter;
import client.MapleCharacterUtil;
import client.MapleClient;
import client.inventory.Item;
import client.inventory.MapleInventoryType;
import configs.ServerConfig;
import handling.channel.ChannelServer;
import handling.chat.ChatServer;
import handling.world.*;
import handling.world.messenger.MapleMessenger;
import handling.world.messenger.MapleMessengerCharacter;
import handling.world.messenger.MessengerType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.MapleItemInformationProvider;
import server.commands.CommandProcessor;
import server.commands.CommandType;
import tools.MaplePacketCreator;
import tools.StringUtil;
import tools.data.input.LittleEndianAccessor;
import tools.packet.ChatPacket;
import tools.packet.MessengerPacket;
import tools.packet.WhisperPacket;






























 public class ChatHandler {
/*  33 */   private static final Logger log = LogManager.getLogger(ChatHandler.class);












   public static void GeneralChat(String text, byte unk, MapleClient c, MapleCharacter chr) {
/*  47 */     if (text.length() > 0 && chr != null && chr.getMap() != null && !CommandProcessor.processCommand(c, text, (chr.getBattle() == null) ? CommandType.NORMAL : CommandType.POKEMON)) {
/*  48 */       if (!chr.isIntern() && text.length() >= 80) {
         return;
       }
/*  51 */       log.info("[信息] " + chr.getName() + " : " + text);
/*  52 */       if (chr.getCanTalk() || chr.isStaff()) {

/*  54 */         if (chr.isHidden()) {
/*  55 */           if (chr.isIntern() && !chr.isSuperGM() && unk == 0) {
/*  56 */             chr.getMap().broadcastGMMessage(chr, MaplePacketCreator.getChatText(chr.getId(), text, chr.getName(), false, 1), true);
/*  57 */             if (unk == 0) {
/*  58 */               chr.getMap().broadcastGMMessage(chr, MaplePacketCreator.serverNotice(2, chr.getName() + " : " + text), true);
             }
           }
/*  61 */           else if (unk == 11) {
/*  62 */             int chatEmoticon = Integer.parseInt(text.replace(":", ""));
/*  63 */             chr.getMap().broadcastGMMessage(chr, MaplePacketCreator.getChatText(chr.getId(), chatEmoticon, "", chr.getName(), c.getPlayer().isSuperGM(), unk), true);
           } else {
/*  65 */             chr.getMap().broadcastGMMessage(chr, MaplePacketCreator.getChatText(chr.getId(), text, chr.getName(), c.getPlayer().isSuperGM(), unk), true);
           }

         } else {

/*  70 */           chr.getCheatTracker().checkMsg();
/*  71 */           if (chr.isIntern() && !chr.isSuperGM() && unk == 0) {
/*  72 */             chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(chr.getId(), text, chr.getName(), false, 1), c.getPlayer().getTruePosition());
/*  73 */             if (unk == 0) {
/*  74 */               chr.getMap().broadcastMessage(MaplePacketCreator.serverNotice(2, chr.getName() + " : " + text), c.getPlayer().getTruePosition());
             }
           }
/*  77 */           else if (chr.haveItem(2430865)) {
/*  78 */             int type = chr.getChatColor();
/*  79 */             chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(chr.getId(), text, chr.getName(), c.getPlayer().isSuperGM(), 2), c.getPlayer().getTruePosition());
/*  80 */             chr.getMap().broadcastMessage(MaplePacketCreator.spouseMessage(type, chr.getName() + "：" + text), c.getPlayer().getTruePosition());
           }
/*  82 */           else if (unk == 11) {
/*  83 */             int chatEmoticon = Integer.parseInt(text.replace(":", ""));
/*  84 */             chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(chr.getId(), chatEmoticon, "", chr.getName(), c.getPlayer().isSuperGM(), unk), c.getPlayer().getTruePosition());
           } else {
/*  86 */             chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(chr.getId(), text, chr.getName(), c.getPlayer().isSuperGM(), unk), c.getPlayer().getTruePosition());
           }
         }


/*  91 */         if (text.equalsIgnoreCase("我喜欢" + c.getChannelServer().getServerName())) {
/*  92 */           chr.finishAchievement(11);
         }
/*  94 */         if (chr.getMap().getId() == 910000000 && ServerConfig.CHANNEL_CHALKBOARD) {
/*  95 */           if (unk == 11) {
/*  96 */             chr.setMarketChalkboard(" ");
           } else {
/*  98 */             chr.setMarketChalkboard(chr.getName() + " : " + text);
           }
         }
       } else {
/* 102 */         c.announce(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk."));
       }
     }
   }



   public static void ItemChat(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
     Item item;
/* 111 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 112 */     String text = slea.readMapleAsciiString();
/* 113 */     byte unk = slea.readByte();
/* 114 */     int ItemType = slea.readInt();
/* 115 */     int Itemslot = slea.readInt();
/* 116 */     String itemName = slea.readMapleAsciiString();

/* 118 */     if (Itemslot < 0) {

/* 120 */       item = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short)Itemslot);
     } else {
/* 122 */       item = c.getPlayer().getInventory(MapleInventoryType.getByType((byte)ItemType)).getItem((short)Itemslot);
     }

/* 125 */     if (text.length() > 0 && chr != null && chr.getMap() != null) {
/* 126 */       if (!chr.isIntern() && text.length() >= 80) {
         return;
       }
/* 129 */       log.info("[道具聊天信息] " + chr.getName() + " : [" + ii.getName(item.getItemId()) + "(" + item.getItemId() + ")]" + text);
/* 130 */       if (chr.getCanTalk()) {
/* 131 */         chr.getCheatTracker().checkMsg();
/* 132 */         chr.getMap().broadcastMessage(MaplePacketCreator.getChatText(true, 0, chr.getId(), text, chr.getName(), false, unk, item, itemName), c.getPlayer().getTruePosition());
       } else {
/* 134 */         c.announce(MaplePacketCreator.serverNotice(6, "你已经被禁言.因此无法说话."));
       }
     }
   } public static void ItemWhisper_Find(LittleEndianAccessor slea, MapleClient c) {
     String recipient;
     int ItemType, Itemslot;
     String text;
     Item item;
     int ch;
/* 143 */     byte mode = slea.readByte();
/* 144 */     slea.readInt();
/* 145 */     switch (mode) {
       case 6:
/* 147 */         if (c.getPlayer() == null || c.getPlayer().getMap() == null) {
           return;
         }
/* 150 */         if (!c.getPlayer().getCanTalk()) {
/* 151 */           c.announce(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk."));
           return;
         }
/* 154 */         c.getPlayer().getCheatTracker().checkMsg();
/* 155 */         recipient = slea.readMapleAsciiString();
/* 156 */         ItemType = slea.readInt();
/* 157 */         Itemslot = slea.readInt();
/* 158 */         text = slea.readMapleAsciiString();

/* 160 */         if (Itemslot < 0) {

/* 162 */           item = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short)Itemslot);
         } else {
/* 164 */           item = c.getPlayer().getInventory(MapleInventoryType.getByType((byte)ItemType)).getItem((short)Itemslot);
         }
/* 166 */         ch = WorldFindService.getInstance().findChannel(recipient);
/* 167 */         if (ch > 0) {
/* 168 */           MapleCharacter player = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(recipient);
/* 169 */           if (player == null) {
             break;
           }
/* 172 */           player.getClient().announce(WhisperPacket.getWhisper(true, c.getPlayer().getName(), c.getChannel(), text, item));
/* 173 */           if (!c.getPlayer().isIntern() && player.isIntern()) {
/* 174 */             c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0));
           } else {
/* 176 */             c.announce(WhisperPacket.getWhisperReply(recipient, (byte)1));
           }
/* 178 */           if (c.isMonitored()) {
/* 179 */             WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, c.getPlayer().getName() + " whispered " + recipient + " : " + text)); break;
/* 180 */           }  if (player.getClient().isMonitored())
/* 181 */             WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, c.getPlayer().getName() + " whispered " + recipient + " : " + text)); 
           break;
         }
/* 184 */         c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0));
         break;
     }
   }





   public static void ItemOthers(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
     Item item;
/* 195 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 196 */     int type = slea.readByte();
/* 197 */     byte numRecipients = slea.readByte();
/* 198 */     if (numRecipients <= 0) {
       return;
     }
/* 201 */     int[] recipients = new int[numRecipients];
     byte i;
/* 203 */     for (i = 0; i < numRecipients; i = (byte)(i + 1)) {
/* 204 */       recipients[i] = slea.readInt();
     }
/* 206 */     String chattext = slea.readMapleAsciiString();
/* 207 */     int ItemType = slea.readInt();
/* 208 */     int Itemslot = slea.readInt();

/* 210 */     if (Itemslot < 0) {

/* 212 */       item = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short)Itemslot);
     } else {
/* 214 */       item = c.getPlayer().getInventory(MapleInventoryType.getByType((byte)ItemType)).getItem((short)Itemslot);
     }

/* 217 */     if (chr == null || !chr.getCanTalk()) {
/* 218 */       c.announce(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk."));

       return;
     }
/* 222 */     log.info("[道具聊天信息] " + chr.getName() + " : [" + ii.getName(item.getItemId()) + "(" + item.getItemId() + ")]" + chattext);
/* 223 */     if (chattext.length() <= 0) {
       return;
     }
/* 226 */     chr.getCheatTracker().checkMsg();
/* 227 */     switch (type) {
       case 0:
/* 229 */         WorldBuddyService.getInstance(); WorldBuddyService.buddyChat(true, recipients, chr.getId(), chattext, item);
         break;
       case 1:
/* 232 */         if (chr.getParty() == null) {
           break;
         }
/* 235 */         WorldPartyService.getInstance().partyChat(true, chr.getParty().getPartyId(), chattext, chr.getName(), item);
         break;
       case 2:
/* 238 */         if (chr.getGuildId() <= 0) {
           break;
         }
/* 241 */         WorldGuildService.getInstance().guildChat(chr.getGuildId(), chr.getName(), chr.getId(), chattext, item);
         break;
       case 3:
/* 244 */         if (chr.getGuildId() <= 0) {
           break;
         }
/* 247 */         WorldAllianceService.getInstance().allianceChat(chr.getGuildId(), chr.getName(), chr.getId(), chattext);
         break;
       case 4:
/* 250 */         if (chr.getParty() == null || chr.getParty().getExpeditionId() <= 0) {
           break;
         }
/* 253 */         WorldPartyService.getInstance().expedChat(true, chr.getParty().getExpeditionId(), chattext, chr.getName(), item);
         break;
     }
   }


   public static void Others(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/* 260 */     int type = slea.readByte();
/* 261 */     byte numRecipients = slea.readByte();
/* 262 */     if (numRecipients <= 0) {
       return;
     }
/* 265 */     int[] recipients = new int[numRecipients];
     byte i;
/* 267 */     for (i = 0; i < numRecipients; i = (byte)(i + 1)) {
/* 268 */       recipients[i] = slea.readInt();
     }
/* 270 */     String chattext = slea.readMapleAsciiString();
/* 271 */     if (chr == null || !chr.getCanTalk()) {
/* 272 */       c.announce(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk."));
       return;
     }
/* 275 */     log.info("[信息] " + chr.getName() + " : " + chattext);
/* 276 */     if (c.isMonitored()) {
/* 277 */       String chattype = "未知";
/* 278 */       switch (type) {
         case 0:
/* 280 */           chattype = "好友";
           break;
         case 1:
/* 283 */           chattype = "组队";
           break;
         case 2:
/* 286 */           chattype = "家族";
           break;
         case 3:
/* 289 */           chattype = "联盟";
           break;
         case 4:
/* 292 */           chattype = "远征";
           break;
       }
/* 295 */       WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM消息] " + MapleCharacterUtil.makeMapleReadable(chr.getName()) + " 在 (" + chattype + ") 中说: " + chattext));
     }
/* 297 */     if (chattext.length() <= 0 || CommandProcessor.processCommand(c, chattext, (chr.getBattle() == null) ? CommandType.NORMAL : CommandType.POKEMON)) {
       return;
     }
/* 300 */     chr.getCheatTracker().checkMsg();
/* 301 */     switch (type) {
       case 0:
/* 303 */         WorldBuddyService.getInstance(); WorldBuddyService.buddyChat(false, recipients, chr.getId(), chattext, null);
         break;
       case 1:
/* 306 */         if (chr.getParty() == null) {
           break;
         }
/* 309 */         WorldPartyService.getInstance().partyChat(false, chr.getParty().getPartyId(), chattext, chr.getName(), null);
         break;
       case 2:
/* 312 */         if (chr.getGuildId() <= 0) {
           break;
         }

/* 316 */         WorldGuildService.getInstance().guildChat(chr.getGuildId(), chr.getName(), chr.getId(), chattext);
         break;
       case 3:
/* 319 */         if (chr.getGuildId() <= 0) {
           break;
         }
/* 322 */         WorldAllianceService.getInstance().allianceChat(chr.getGuildId(), chr.getName(), chr.getId(), chattext);
         break;
       case 4:
/* 325 */         if (chr.getParty() == null || chr.getParty().getExpeditionId() <= 0) {
           break;
         }
/* 328 */         WorldPartyService.getInstance().expedChat(false, chr.getParty().getExpeditionId(), chattext, chr.getName(), null);
         break;
     }
   } public static void Messenger(LittleEndianAccessor slea, MapleClient c) {
     int mode, maxMembers, messengerId;
     String targeted;
     MapleCharacter target;
/* 335 */     MapleMessenger messenger = c.getPlayer().getMessenger();
/* 336 */     WorldMessengerService messengerService = WorldMessengerService.getInstance();
/* 337 */     int action = slea.readByte();
/* 338 */     switch (action) {
       case 0:
/* 340 */         if (messenger != null) {
/* 341 */           MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(c.getPlayer());
/* 342 */           messengerService.leaveMessenger(messenger.getId(), messengerplayer);
/* 343 */           c.getPlayer().setMessenger(null);
         }
/* 345 */         mode = slea.readByte();
/* 346 */         maxMembers = slea.readByte();
/* 347 */         messengerId = slea.readInt();

/* 349 */         if (messengerId == 0) {
/* 350 */           MapleMessengerCharacter messengerPlayer = new MapleMessengerCharacter(c.getPlayer());
/* 351 */           MessengerType type = MessengerType.getMessengerType(maxMembers, (mode != 0));
/* 352 */           if (type == null) {
/* 353 */             System.out.println("聊天招待操作 → 打开 模式为空");
             return;
           }
/* 356 */           if (mode == 0) {
/* 357 */             c.getPlayer().setMessenger(messengerService.createMessenger(messengerPlayer, type, c.getPlayer().isIntern()));
/* 358 */           } else if (mode == 1) {
/* 359 */             messenger = c.getPlayer().isIntern() ? messengerService.getRandomHideMessenger(type) : messengerService.getRandomMessenger(type);
/* 360 */             if (messenger != null) {
/* 361 */               int position = messenger.getLowestPosition();
/* 362 */               if (position != -1) {
/* 363 */                 c.getPlayer().setMessenger(messenger);
/* 364 */                 messengerService.joinMessenger(messenger.getId(), new MapleMessengerCharacter(c.getPlayer()), c.getPlayer().getName(), c.getChannel());
               }
             } else {
/* 367 */               c.getPlayer().setMessenger(messengerService.createMessenger(messengerPlayer, type, c.getPlayer().isIntern()));
/* 368 */               c.announce(MessengerPacket.joinMessenger(255));
             }
           }
         } else {
/* 372 */           messenger = messengerService.getMessenger(messengerId);
/* 373 */           if (messenger != null) {
/* 374 */             int position = messenger.getLowestPosition();
/* 375 */             if (position != -1) {
/* 376 */               c.getPlayer().setMessenger(messenger);
/* 377 */               messengerService.joinMessenger(messenger.getId(), new MapleMessengerCharacter(c.getPlayer()), c.getPlayer().getName(), c.getChannel());
             }
           }
         }

       case 2:
/* 383 */         if (messenger != null) {
/* 384 */           MapleMessengerCharacter messengerplayer = new MapleMessengerCharacter(c.getPlayer());
/* 385 */           messengerService.leaveMessenger(messenger.getId(), messengerplayer);
/* 386 */           c.getPlayer().setMessenger(null);
         }

       case 3:
/* 390 */         if (messenger != null) {
/* 391 */           int position = messenger.getLowestPosition();
/* 392 */           if (position == -1) {
/* 393 */             System.out.println("聊天招待操作 → 邀请错误 没有空闲的位置");
             return;
           }
/* 396 */           String input = slea.readMapleAsciiString();
/* 397 */           MapleCharacter mapleCharacter = c.getChannelServer().getPlayerStorage().getCharacterByName(input);
/* 398 */           if (mapleCharacter != null) {
/* 399 */             if (!mapleCharacter.isIntern() || c.getPlayer().isIntern()) {
/* 400 */               c.announce(MessengerPacket.messengerNote(input, 4, 1));
/* 401 */               mapleCharacter.getClient().announce(MessengerPacket.messengerInvite(c.getPlayer().getName(), messenger.getId(), c.getChannel() - 1));
             } else {
/* 403 */               c.announce(MessengerPacket.messengerNote(input, 4, 1));
             }

/* 406 */           } else if (World.isConnected(input)) {
/* 407 */             messengerService.messengerInvite(c.getPlayer().getName(), messenger.getId(), input, c.getChannel(), c.getPlayer().isIntern());
           } else {
/* 409 */             c.announce(MessengerPacket.messengerNote(input, 4, 0));
           }
         }


       case 5:
/* 415 */         targeted = slea.readMapleAsciiString();
/* 416 */         target = c.getChannelServer().getPlayerStorage().getCharacterByName(targeted);
/* 417 */         if (target != null) {
/* 418 */           if (target.getMessenger() != null) {
/* 419 */             target.getClient().announce(MessengerPacket.messengerNote(c.getPlayer().getName(), 5, 0));
           }
         }
/* 422 */         else if (!c.getPlayer().isIntern()) {
/* 423 */           messengerService.declineChat(targeted, c.getPlayer().getName());
         }


       case 6:
/* 428 */         if (messenger != null) {
/* 429 */           String chattext = slea.readMapleAsciiString();
/* 430 */           String position = null;
/* 431 */           if (slea.available() > 0L) {
/* 432 */             position = slea.readMapleAsciiString();
           }
/* 434 */           messengerService.messengerChat(messenger.getId(), chattext, c.getPlayer().getName(), position);
/* 435 */           if (messenger.isMonitored() && chattext.length() > c.getPlayer().getName().length() + 3) {
/* 436 */             WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM消息] " + MapleCharacterUtil.makeMapleReadable(c.getPlayer().getName()) + "(Messenger: " + messenger.getMemberNamesDEBUG() + ") said: " + chattext));
           }
         }

       case 9:
/* 441 */         if (messenger != null) {
/* 442 */           String name = slea.readMapleAsciiString();
/* 443 */           if (!(messenger.getType()).random) {
/* 444 */             System.out.println("聊天招待操作 → 对别人增加好感度错误 聊天室的类型不是随机聊天 : " + (!(messenger.getType()).random ? 1 : 0));
             return;
           }
/* 447 */           MapleCharacter targetPlayer = WorldFindService.getInstance().findCharacterByName(name);
/* 448 */           if (targetPlayer != null && targetPlayer.getId() != c.getPlayer().getId() && targetPlayer.getMessenger() != null && targetPlayer.getMessenger().getId() == messenger.getId()) {
/* 449 */             switch (c.getPlayer().canGiveLove(targetPlayer)) {
               case 0:
/* 451 */                 if (Math.abs(targetPlayer.getLove() + 1) <= 99999) {
/* 452 */                   targetPlayer.addLove(1);
/* 453 */                   targetPlayer.getClient().announce(MessengerPacket.updateLove(targetPlayer.getLove()));
                 }
/* 455 */                 c.getPlayer().hasGiveLove(targetPlayer);
/* 456 */                 c.announce(MessengerPacket.giveLoveResponse(0, c.getPlayer().getName(), targetPlayer.getName()));
/* 457 */                 targetPlayer.getClient().announce(MessengerPacket.giveLoveResponse(0, c.getPlayer().getName(), targetPlayer.getName()));
                 break;
               case 1:
/* 460 */                 c.announce(MessengerPacket.giveLoveResponse(1, c.getPlayer().getName(), targetPlayer.getName()));
                 break;
               case 2:
/* 463 */                 c.announce(MessengerPacket.giveLoveResponse(2, c.getPlayer().getName(), targetPlayer.getName()));
                 break;
             }

           }
         }

       case 11:
/* 471 */         if (messenger != null) {
/* 472 */           String name = slea.readMapleAsciiString();
/* 473 */           MapleCharacter player = WorldFindService.getInstance().findCharacterByName(name);
/* 474 */           if (player != null) {
/* 475 */             if (player.getMessenger() != null && player.getMessenger().getId() == messenger.getId()) {
/* 476 */               c.announce(MessengerPacket.messengerPlayerInfo(player));
             }
           } else {
/* 479 */             c.announce(MessengerPacket.messengerNote(name, 4, 0));
           }
         }


       case 14:
/* 485 */         if (messenger != null) {
/* 486 */           String namefrom = slea.readMapleAsciiString();
/* 487 */           String chattext = slea.readMapleAsciiString();
/* 488 */           int position = slea.readByte();
/* 489 */           messengerService.messengerWhisper(messenger.getId(), chattext, namefrom, position);
         }


       case 15:
         return;
     }

/* 497 */     System.out.println("聊天招待操作( 0x" + StringUtil.getLeftPaddedStr(Integer.toHexString(action).toUpperCase(), '0', 2) + " ) 未知.");
   } public static void Whisper_Find(LittleEndianAccessor slea, MapleClient c) {
     String recipient;
     MapleCharacter player;
     String text;
     int ch;
/* 503 */     byte mode = slea.readByte();
/* 504 */     slea.readInt();
/* 505 */     switch (mode) {
       case 5:
       case 68:
/* 508 */         recipient = slea.readMapleAsciiString();
/* 509 */         player = c.getChannelServer().getPlayerStorage().getCharacterByName(recipient);
/* 510 */         if (player != null) {
/* 511 */           if (!player.isIntern() || (c.getPlayer().isIntern() && player.isIntern())) {
/* 512 */             c.announce(WhisperPacket.getFindReplyWithMap(player.getName(), player.getMap().getId(), (mode == 68))); break;
           }
/* 514 */           c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0, player.getName()));
           break;
         }
/* 517 */         ch = WorldFindService.getInstance().findChannel(recipient);
/* 518 */         if (ch > 0) {
/* 519 */           player = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(recipient);
/* 520 */           if (player == null) {
             break;
           }
/* 523 */           if (!player.isIntern() || (c.getPlayer().isIntern() && player.isIntern())) {
/* 524 */             c.announce(WhisperPacket.getFindReply(recipient, (byte)ch, (mode == 68)));
           } else {
/* 526 */             c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0, player.getName()));
           }
           return;
         }
/* 530 */         if (ch == -10) {
/* 531 */           c.announce(WhisperPacket.getFindReplyWithCS(recipient, (mode == 68))); break;
/* 532 */         }  if (ch == -20) {
/* 533 */           c.getPlayer().dropMessage(5, "'" + recipient + "' is at the MTS."); break;
         }
/* 535 */         c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0, player.getName()));
         break;



       case 6:
/* 541 */         if (c.getPlayer() == null || c.getPlayer().getMap() == null) {
           return;
         }
/* 544 */         if (!c.getPlayer().getCanTalk()) {
/* 545 */           c.announce(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk."));
           return;
         }
/* 548 */         c.getPlayer().getCheatTracker().checkMsg();
/* 549 */         recipient = slea.readMapleAsciiString();
/* 550 */         text = slea.readMapleAsciiString();
/* 551 */         ch = WorldFindService.getInstance().findChannel(recipient);
/* 552 */         if (ch > 0) {
/* 553 */           MapleCharacter mapleCharacter = ChannelServer.getInstance(ch).getPlayerStorage().getCharacterByName(recipient);
/* 554 */           if (mapleCharacter == null) {
             break;
           }
/* 557 */           mapleCharacter.getClient().announce(WhisperPacket.getWhisper(c.getPlayer().getName(), c.getChannel(), text));
/* 558 */           if (!c.getPlayer().isIntern() && mapleCharacter.isIntern()) {
/* 559 */             c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0, mapleCharacter.getName()));
           } else {
/* 561 */             c.announce(WhisperPacket.getWhisperReply(recipient, (byte)1, mapleCharacter.getName()));
           }
/* 563 */           if (c.isMonitored()) {
/* 564 */             WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, c.getPlayer().getName() + " whispered " + recipient + " : " + text)); break;
/* 565 */           }  if (mapleCharacter.getClient().isMonitored())
/* 566 */             WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, c.getPlayer().getName() + " whispered " + recipient + " : " + text)); 
           break;
         }
/* 569 */         c.announce(WhisperPacket.getWhisperReply(recipient, (byte)0, c.getPlayer().getName()));
         break;
     }
   }



   public static void ShowLoveRank(LittleEndianAccessor slea, MapleClient c) {
/* 577 */     byte mode = slea.readByte();
/* 578 */     switch (mode) {
       case 7:
/* 580 */         c.announce(MessengerPacket.showLoveRank(7));
         break;
       case 8:
/* 583 */         c.announce(MessengerPacket.showLoveRank(8));
         break;
     }
   }


   public static void EnterChatServer(LittleEndianAccessor slea, MapleClient c) {
/* 590 */     if (ChatServer.isShutdown()) {
       return;
     }

/* 594 */     slea.skip(17);
/* 595 */     int chrid = slea.readInt();

/* 597 */     slea.skip(slea.readShort());


/* 600 */     MapleCharacter chr = WorldFindService.getInstance().findCharacterById(chrid);
/* 601 */     if (chr == null) {
       return;
     }
/* 604 */     chr.setChatSession(c.getSession());
/* 605 */     c.announce(ChatPacket.getChatLoginAUTH());
/* 606 */     c.announce(ChatPacket.getChatLoginResult(chr.getClient()));
   }







   public static void BuddyChat(LittleEndianAccessor slea, MapleClient c) {
/* 616 */     int playerid = slea.readInt();
/* 617 */     String chattext = slea.readMapleAsciiString();
/* 618 */     int numRecipients = slea.readInt();
/* 619 */     int[] recipients = new int[numRecipients];
     byte i;
/* 621 */     for (i = 0; i < numRecipients; i = (byte)(i + 1)) {
/* 622 */       recipients[i] = slea.readInt();
     }
/* 624 */     WorldBuddyService.getInstance(); WorldBuddyService.buddyChat(recipients, playerid, chattext);
   }







    /**
     * 处理家族聊天
     *
     * @param slea
     * @param c
     */
    public static void GuildChat(LittleEndianAccessor slea, MapleClient c) {
        int playerid = slea.readInt();
        int guildid = slea.readInt();
        String chattext = slea.readMapleAsciiString();

        MapleCharacter chr = WorldFindService.getInstance().findCharacterById(playerid);
        if (chr == null) {
            return;
        }
        WorldGuildService.getInstance().guildChat(chr.getAccountID(), guildid+"", playerid, chattext);
    }
 }

